//
//  adddViewController.m
//  CNKICommunity
//
//  Created by wei on 17/1/20.
//  Copyright © 2017年 CNKI. All rights reserved.
//

#import "adddViewController.h"
#import "NetWorkingUtils.h"
#import "SencondViewController.h"
#import "CNKIScrollview.h"
@interface adddViewController ()<CNKIScrollviewClickDelegate>

@property(nonatomic,strong)UILabel *PracticLabel;
@property(nonatomic,strong)NSString *haha;
@end

@implementation adddViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _PracticLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 190, 30)];
    _PracticLabel.font = [UIFont systemFontOfSize:15];
    _PracticLabel.backgroundColor = [UIColor lightGrayColor];
    _PracticLabel.textColor = [UIColor redColor];
    [self.view addSubview:_PracticLabel];
    
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 200, 100, 100)];
    [imageView sd_setImageWithURL:[NSURL URLWithString:@"https://placemat.imgix.net/placeholder_images/images/000/000/043/original/photo-1428604422807-314cf752cbc9?ixlib=rb-1.0.0&w=&h=&fm=auto&crop=faces%2Centropy&fit=crop&txt=&txtclr=BFFF&txtalign=middle%2Ccenter&txtfit=max&txtsize=42&txtfont=Avenir+Next+Demi%2CBold&bm=multiply&blend=ACACAC&s=962f319e5c6b3826b17f7554ccbf1c4b"] placeholderImage:[UIImage imageNamed:@"Welcome_3.0_5.jpg"] options:SDWebImageAllowInvalidSSLCertificates completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        
    }];
    imageView.userInteractionEnabled = YES;
    [self.view addSubview:imageView];
    
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(jumpNextPage)];
    tap.numberOfTouchesRequired = 1;
    tap.numberOfTapsRequired = 1;
    [imageView addGestureRecognizer:tap];
    
    
    
   [[HttpsRefreshNetworking Networking] GET:[NSString stringWithFormat:@"http://192.168.22.246/WebApiTest/Message/GetMessage/10"] parameters:nil success:^(NSDictionary *allHeaders, id responseObject, id statusCode) {
            NSLog(@"%@",responseObject);
        } failure:^(NSDictionary *allHeaders, NSError *error, id statusCode) {
    
        }];
    
    
    //网络检测
    __block typeof(self)weakself = self;
    [NetWorkingUtils netWorkstate:^(NSInteger netState) {
        switch (netState) {
            case 1:{
                NSLog(@"手机流量上网");
            }
                break;
            case 2:{
                NSLog(@"WIFI上网");
                weakself.view.backgroundColor = [UIColor greenColor];
            }
                break;
            default:{
                NSLog(@"没网");
                weakself.view.backgroundColor = [UIColor redColor];
            }
                break;
        }
    }];

    //[self setUpScorllView];
}
-(void)setUpScorllView
{
    CNKIScrollview *NormalScorllview = [[CNKIScrollview alloc]initWithFrame:CGRectMake(0, 64, 90, SCREENHEIGHT - 64)];
    NormalScorllview.CNKIScrollviewDelegate = self;
    NSArray *arr = @[@"医学",@"数学",@"物理",@"农学",@"天文",@"地理",@"大气",@"海洋",@"地球物理",@"地质",@"生物",@"系统科学",@"生态",@"统计",@"力学",@"金属学及工艺",@"中医和中西医结合",@"观赏园艺与园林",@"农业资源与管理",@"植物保护"];
    NormalScorllview.ButtonContent = arr;
    [self.view addSubview:NormalScorllview];
}
-(void)clickBtnId:(NSInteger)BtnId BtnName:(NSString *)Name
{
    NSLog(@"点击的是%@",Name);
    if ([_haha isEqualToString:Name])
    {
       _PracticLabel.text = [NSString stringWithFormat:@"还点,小心我射爆你的蛋蛋"];
    }
    else
    {
       _PracticLabel.text = [NSString stringWithFormat:@"不错哦小伙,你很喜欢%@",Name];
        _haha = Name;
    }
}
-(void)jumpNextPage
{
    [self presentViewController:[SencondViewController new] animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
